# web自动化测试-day3
# 1. 注册实例页面,3个表单的注册操作
# 2. 注册页面的select下拉练习
# 3. 注册页面的alter练习
# 4. 登录qq邮箱[选做]
# 5. 登录163邮箱[选做]
# 6. 使用163邮箱发邮件[选做]
# > 注意:提交作业的时候,不要提交真实的qq账号和密码


from selenium import webdriver
from selenium.webdriver.common.by import By
import os
from time import sleep

class Login:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('file:///'+os.path.dirname(os.path.abspath('html'))+'/注册实例.html')

    def zc(self):
        self.user = self.driver.find_element(By.ID, "user")
        sleep(2)
        self.user.send_keys('123456')
        sleep(2)
        pwd = self.driver.find_element(By.ID, "password")
        pwd.send_keys('123456')
        sleep(1)
        tel = self.driver.find_element(By.ID, "tel")
        tel.send_keys("11111111111")
        sleep(1)
        email = self.driver.find_element(By.ID, "email")
        email.send_keys("123456@qq.com")
        sleep(1)
        btn = self.driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
        btn.click()
        sleep(2)

    def zca(self):
        self.driver.switch_to.frame('idframe1')
        self.driver.find_element(By.ID, "userA")
        # print(zca.get_attribute('outerHTML'))

        userA = self.driver.find_element(By.ID, "userA")
        userA.send_keys('654321')
        sleep(2)
        passwordA = self.driver.find_element(By.ID, "passwordA")
        passwordA.send_keys('654321')
        sleep(2)
        telA = self.driver.find_element(By.ID, "telA")
        telA.send_keys("12345678912")
        sleep(2)
        emailA = self.driver.find_element(By.ID, "emailA")
        emailA.send_keys('654321@qq.com')
        sleep(2)
        btnA = self.driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
        btnA.click()




if __name__ == '__main__':
    login = Login()
    login.zc()

# # TODO 会员注册A
driver.switch_to.frame('idframe1')
zca = driver.find_element(By.ID, "userA")
# print(zca.get_attribute('outerHTML'))
userA = driver.find_element(By.ID, "userA")
userA.send_keys('654321')
sleep(2)
passwordA = driver.find_element(By.ID, "passwordA")
passwordA.send_keys('654321')
sleep(2)
telA = driver.find_element(By.ID, "telA")
telA.send_keys("12345678912")
sleep(2)
emailA = driver.find_element(By.ID, "emailA")
emailA.send_keys('654321@qq.com')
sleep(2)
btnA = driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
btnA.click()

# TODO 会员注册B
sleep(2)
driver.switch_to.default_content()
driver.switch_to.frame('myframe2')
zcb = driver.find_element(By.ID, 'userB')
userB = driver.find_element(By.ID, "userB")
print(userB)
userB.send_keys('654321')
sleep(2)
passwordB = driver.find_element(By.ID, "passwordB")
passwordB.send_keys('654321')
sleep(2)
telB = driver.find_element(By.ID, "telB")
telB.send_keys("12345678912")
sleep(2)
emailB = driver.find_element(By.ID, "emailB")
emailB.send_keys('654321@qq.com')
sleep(2)
btnB = driver.find_element(By.XPATH, '//*[@id="zc"]/fieldset/button')
btnB.click()

sleep(2)
driver.quit()
